<template>
	<view class="">
		<view class="cont" v-if="type==1">
			<BaseHouseMessage title="所在小区" :content="obj.community_name" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房屋名称" :content="obj.house.name" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房源总价" :content="obj.house.price+'万'" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="建筑面积" :content="obj.house.building_area+'㎡'" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房源价格" :content="obj.house.unit_price+'元/㎡'" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="挂牌日期" :content="obj.house.listed" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="建筑年份" :content="obj.house.build_date" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房屋年份" :content="obj.house.house_year+'年'" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="梯户比" :content="obj.house.ladder_house_scale" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="楼层" :content="obj.house.the_floor" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="所在楼层" :content="obj.house.floor" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="总楼层" :content="obj.house.total_floors" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="户型" :content="obj.house.room+'室'+obj.house.hall+'厅'+obj.house.rest_room+'卫'"
				:isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房型" :content="obj.house.house_type" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="朝向" :content="obj.house.orientation" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="用途" :content="obj.house.purpose" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="建筑类型" :content="obj.house.build_type" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="权属" :content="obj.house.ownerships" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="是否电梯" :content="obj.house.elevator" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房源特色" :content="obj.house.house_features" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="保安管理" :content="obj.guard_name" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="简介" :content="obj.house.descriptions" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="看房说明" :content="obj.house.see_house" :isBlock="true"></BaseHouseMessage>
			<view class="" v-if="obj.house.landlord==1">
				<BaseHouseMessage title="业主姓名" :content="obj.contact" :isBlock="true"></BaseHouseMessage>
				<BaseHouseMessage title="业主电话" :content="obj.contact_number" :isBlock="true"></BaseHouseMessage>
			</view>
			<view class="biaoqian">
				<text class="left">标签：</text>
				<text class="right" v-for="(item,index) in obj.house.label" :key="index">{{item}}</text>
			</view>
			<view class="tupianbox">
				<text class="name">房屋封面：</text>
				<image :src="obj.house.image" mode="" @click="erfen(obj.house.image,false)"></image>
			</view>
			<view class="tupianbox">
				<text class="name">详情图片：</text>
				<image v-for="(item,index) in obj.house.banner" :key="index" :src="item" mode=""
					@click="erfen(obj.house.banner,true,index)"></image>
			</view>
		</view>
		<view class="cont" v-if="type==2">
			<BaseHouseMessage title="所在小区" :content="obj.community_name" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="租房名称" :content="obj.house.name" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="每月租金" :content="obj.house.price+'元/月'" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="建筑面积" :content="obj.house.building_area+'㎡'" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="楼层" :content="obj.house.the_floor" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="所在楼层" :content="obj.house.floor" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="总楼层" :content="obj.house.total_floors" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="出租方式" :content="obj.house.rent_type" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房屋租期" :content="obj.house.rent_term" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="付款方式" :content="obj.house.pay_type" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="是否有燃气" :content="obj.house.have_gas==0?'没有':'有'" :isBlock="true">
			</BaseHouseMessage>
			<BaseHouseMessage title="是否有车位" :content="obj.house.have_parking==0?'没有':'有'" :isBlock="true">
			</BaseHouseMessage>
			<BaseHouseMessage title="朝向" :content="obj.house.orientation" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房源亮点" :content="obj.house.house_bright" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="配套设施" :content="obj.house.facilities" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="是否电梯" :content="obj.house.elevator" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="是否权属核验" :content="obj.house.ownership" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="装修标准" :content="obj.house.decorate" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="供水" :content="obj.house.water_supply" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="供暖" :content="obj.house.heating_supply" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="供电" :content="obj.house.power_supply" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="户型" :content="obj.house.room+'室'+obj.house.hall+'厅'+obj.house.rest_room+'卫'"
				:isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="房型" :content="obj.house.house_type" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="保安管理" :content="obj.guard_name" :isBlock="true"></BaseHouseMessage>
			<BaseHouseMessage title="看房说明" :content="obj.house.see_house" :isBlock="true"></BaseHouseMessage>
			<view class="" v-if="obj.house.landlord==1">
				<BaseHouseMessage title="业主姓名" :content="obj.contact" :isBlock="true"></BaseHouseMessage>
				<BaseHouseMessage title="业主电话" :content="obj.contact_number" :isBlock="true"></BaseHouseMessage>
			</view>
			<view class="biaoqian">
				<text class="left">标签：</text>
				<text class="right" v-for="(item,index) in obj.house.label" :key="index">{{item}}</text>
			</view>
			<view class="tupianbox">
				<text class="name">房屋封面：</text>
				<image :src="obj.house.image" mode="" @click="erfen(obj.house.image,false)"></image>
			</view>
			<view class="tupianbox">
				<text class="name">详情图片：</text>
				<image v-for="(item,index) in obj.house.banner" :key="index" :src="item" mode=""
					@click="erfen(obj.house.banner,true,index)"></image>
			</view>
		</view>
		
		<u-popup v-model="show" mode="center">
			<view class="tangchubox">
				<textarea :value="remark" placeholder="请输入不通过原因" class="reason" @input="shuru" />
				<view class="submits" @click="submit(obj)">
					提交
				</view>
			</view>
		</u-popup>
		
		<view class="caozuo">
			<view class="nopass" @click="nopass">
				不通过
			</view>
			<view class="pass" @click="pass(obj)">
				通过审核
			</view>
		</view>
	</view>
</template>

<script>
	import BaseHouseMessage from "../../components/BaseHouseMessage/index.vue"; //小信息
	import {
		gethousefinish,
		getselect,
		getPtSS,
		getaudithouse
	} from "../../api/api/index"
	export default {
		data() {
			return {
				id: 0,
				show: false,
				obj: {},
				type: 1,
				remark:""
			}
		},
		components: {
			BaseHouseMessage
		},
		onLoad(e) {
			this.type = e.type
			gethousefinish({
				id: e.id
			}).then(res => {
				this.obj = res.data
				if (res.data.type == 2) {
					// 根据配套设施接口的ID和获取数据的ID做比较筛选出相同的id值
					getPtSS().then(res => {
						let facilitiesarr = this.obj.house.facilities
						let facilitiesarrs = res.data
						let arr = []
						for (let i = 0; i < facilitiesarrs.length; i++) {
							for (let j = 0; j < facilitiesarr.length; j++) {
								if (facilitiesarrs[i].id == facilitiesarr[j]) {
									// console.log()
									arr.push(facilitiesarrs[j].name)
								}
							}
						}
						this.obj.house.facilities = arr.join(",")
					})
					// 根据付款方式接口的ID和获取数据的ID做比较筛选出相同的id值
					getselect({
						type: "pay_type"
					}).then(res => {
						let paytypearr = res.data.pay_type.child
						for (let i = 0; i < paytypearr.length; i++) {
							if (paytypearr[i].id = this.obj.house.pay_type) {
								this.obj.house.pay_type = paytypearr[i].name
							}
						}
					})
				}
			})

		},
		methods: {
			// bool用来判断是组数还是字符串
			erfen(url, bool, index) {
				if (bool) {
					uni.previewImage({
						urls: url,
						current: url[index]
					})
				} else {
					let arr = [url]
					uni.previewImage({
						urls: arr,
						current: url[0]
					})
				}
			},
			// 审核通过
			pass(v){
				let data={id:v.id,audit:1}
				getaudithouse(data).then(res=>{
					uni.showToast({
						title:res.message,
						icon:"none",
						duration:1500
					})
					setTimeout(function(){
						uni.navigateBack({})
					},1500)
				})
			},
			// 审核不通过
			nopass(){
				this.show=true
			},
			// 提交审核不通过原因
			shuru(e){
				this.remark=e.detail.value
			},
			submit(v){
				let data={id:v.id,reason:this.remark,audit:2}
				getaudithouse(data).then(res=>{
					uni.showToast({
						title:res.message,
						icon:"none",
						duration:1500
					})
					setTimeout(function(){
						uni.navigateBack({})
					},1500)
				})
				
			}
		},
		onShow() {

		}
	}
</script>

<style scoped lang="less">
	.cont {
		padding: 50rpx 20rpx;
	}

	.biaoqian {
		display: flex;
		align-items: center;

		.left {
			color: #999999;
			font-family: MicrosoftYaHei;
			font-size: 24rpx;
			font-weight: normal;
		}

		.right {
			width: 104rpx;
			height: 54rpx;
			border: 1rpx solid #e62129;
			border-radius: 10rpx;
			color: #e62129;
			line-height: 50rpx;
			text-align: center;
			display: block;
			font-family: MicrosoftYaHei;
			font-size: 24rpx;
			font-weight: normal;
			font-stretch: normal;
			letter-spacing: 0rpx;
			margin-right: 10rpx;
		}
	}

	.tupianbox {
		display: flex;
		align-items: center;
		margin-top: 20rpx;

		.name {
			color: #999999;
			font-family: MicrosoftYaHei;
			font-size: 24rpx;
			font-weight: normal;
		}

		image {
			width: 100rpx;
			height: 100rpx;
			border-radius: 10rpx;
			margin-right: 10rpx;
		}
	}

	.caozuo {
		display: flex;
		justify-content: space-around;
		align-items: center;
		margin-top: 30rpx;
		margin-bottom: 30rpx;

		.nopass {
			width: 250rpx;
			height: 70rpx;
			color: #393939;
			text-align: center;
			line-height: 68rpx;
			border-radius: 35rpx;
			border-radius: 31rpx;
			border: 3rpx solid #5f5f5f;
			font-size: 26rpx;
		}

		.pass {
			width: 250rpx;
			height: 70rpx;
			text-align: center;
			line-height: 68rpx;
			border-radius: 35rpx;
			color: #d72f2c;
			font-size: 26rpx;
			border-radius: 31rpx;
			border: solid 3rpx #df4744;
		}
	}
	.tangchubox{
		width: 658rpx;
		.reason{
			font-size: 30rpx;
			padding: 20rpx;
			box-sizing: border-box;
		}
		.submits{
			width: 658rpx;
			height: 100rpx;
			text-align: center;
			line-height: 100rpx;
			background-color: #ef0000;
			color: #FFFFFF;
		}
	}
</style>
